
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       mode_initializing.c
  * @author     baiyang
  * @date       2023-7-5
  ******************************************************************************
  */

/*----------------------------------include-----------------------------------*/
#include "mode.h"
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/

/*---------------------------------prototype----------------------------------*/
static enum ModeNumber minit_number(mode_base_const_t mode);
static const char *minit_name(mode_base_const_t mode);
static const char *minit_name4(mode_base_const_t mode);
static bool minit_enter(mode_base_t mode);
static void minit_update(mode_base_t mode);
static bool minit_allows_throttle_nudging(mode_base_const_t mode);
static bool minit_does_auto_throttle(mode_base_const_t mode);
static bool minit_pre_arm_checks(mode_base_const_t mode, size_t buflen, char *buffer);
/*----------------------------------variable----------------------------------*/
static struct mode_ops mode_initializing_ops = {
        .run                                = NULL,
        .mode_number                        = minit_number,
        .name                               = minit_name,
        .name4                              = minit_name4,
        .update                             = minit_update,
        .is_vtol_mode                       = NULL,
        .is_vtol_man_throttle               = NULL,
        .is_vtol_man_mode                   = NULL,
        .is_guided_mode                     = NULL,
        .allows_terrain_disable             = NULL,
        .does_automatic_thermal_switch      = NULL,
        .navigate                           = NULL,
        .allows_throttle_nudging            = minit_allows_throttle_nudging,
        .does_auto_navigation               = NULL,
        .does_auto_throttle                 = minit_does_auto_throttle,
        .mode_allows_autotuning             = NULL,
        .update_target_altitude             = NULL,
        .handle_guided_request              = NULL,
        ._enter                             = minit_enter,
        ._exit                              = NULL,
        ._pre_arm_checks                    = minit_pre_arm_checks};
/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
void minit_ctor(struct ModeInitializing *mode_initializing)
{
    mode_ctor(&mode_initializing->mode, &mode_initializing_ops);
}

// returns a unique number specific to this mode
static enum ModeNumber minit_number(mode_base_const_t mode)
{
    (void)mode;
    return MN_INITIALISING;
}

// returns full text name
static const char *minit_name(mode_base_const_t mode)
{
    (void)mode;
    return "INITIALISING";
}

// returns a string for this flightmode, exactly 4 bytes
static const char *minit_name4(mode_base_const_t mode)
{
    (void)mode;
    return "INIT";
}

// subclasses override this to perform checks before entering the mode
static bool minit_enter(mode_base_t mode)
{
    (void)mode;
    return false;
}

// convert user input to targets, implement high level control for this mode
static void minit_update(mode_base_t mode)
{
    (void)mode;
}

// this allows certain flight modes to mix RC input with throttle
// depending on airspeed_nudge_cm
static bool minit_allows_throttle_nudging(mode_base_const_t mode)
{
    (void)mode;
    return true;
}

// true if the mode sets the vehicle destination, which controls
// whether control input is ignored with STICK_MIXING=0
static bool minit_does_auto_throttle(mode_base_const_t mode)
{
    (void)mode;
    return true;
}

// mode specific pre-arm checks
static bool minit_pre_arm_checks(mode_base_const_t mode, size_t buflen, char *buffer)
{
    (void)mode;
    (void)buflen;
    (void)buffer;

    return false;
}
/*------------------------------------test------------------------------------*/


